package Master;

import Module.WorkUnit;

/*
 * The WorkerTaskUnit implements the WorkUnit interface
 * and it will be as an argument of methods when invoking
 * the methods of WorkService so that the worker can get
 * the related information about the task.
 */
public class WorkerTaskUnit implements WorkUnit{

    /* The identification of this workunit*/
    private int workUnitID;

    /* The program body */
    private byte[] programBody;

    /* The program name */
    private String programName;

    /* The argument of execute program */
    private String[] arguments;

    /* The name of data file */
    private String datafileName;

    /* The bytes of data file */
    private byte[] datafile;

    /* The name of output file */
    private String outputFileName;

    /*
     * Initialize the WorkerTaskUnit which will be sent
     * to workers.
     */
    public WorkerTaskUnit(int workUnitID,
                          String programName, String[] arguments,
                          String datafileName, String outputFileName){
        this.workUnitID = workUnitID;
        this.programName = programName;
        this.arguments = arguments;
        this.datafileName = datafileName;
        this.outputFileName = outputFileName;
    }

    /* Set the program body */
    public void setProgramBody(byte[] programBody){
        this.programBody = programBody;
    }

    /* Set the data file for input to the program*/
    public void setDatafile(byte[] datafile){
        this.datafile = datafile;
    }

    /* Get the id of this work unit */
    public int getWorkUnitID(){
        return workUnitID;
    }

    /* Get the program body */
    public byte[] getProgramBody(){
        return programBody;
    }

    /* Get the program name */
    public String getProgramName(){
        return programName;
    }

    /* Get the arugment of execute program */
    public String[] getArguments(){
        return arguments;
    }

    /* Get the name of data file */
    public String getDatafileName(){
        return datafileName;
    }

    /* Get the data file */
    public byte[] getDatafile(){
        return datafile;
    }

    /* Get the name of output file */
    public String getOutputFileName(){
        return outputFileName;
    }
}
